<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
 
    <title>登录页</title>
    <link href="http://layui.hcwl520.com.cn/layui-v2.4.5/css/layui.css?v=201811010202" rel="stylesheet"></link>
    <link rel="stylesheet" href="http://47556.cn/css/style.css">
 
</head>
<body>
 
<div class="login-main">
    <header class="layui-elip">登录</header>
    <form class="layui-form">
        <div class="layui-input-inline">
            <input type="text" name="email" required lay-verify="required" placeholder="邮箱" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" placeholder="密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline login-btn">
            <button lay-submit lay-filter="login" class="layui-btn">登录</button>
        </div>
        <hr/>
        <p><a href="/user/toRegister" class="fl">立即注册</a><a href="javascript:;" class="fr">忘记密码？</a></p>
    </form>
</div>
 
 
<script type="text/javascript" src="http://layui.hcwl520.com.cn/jquery/jquery-3.3.1.min.js?v=201804251754"></script>
<script type="text/javascript" src="http://layui.hcwl520.com.cn/layui-v2.4.5/layui.all.js?v=201811010202"></script>
<script type="text/javascript">
    layui.use(['form','layer','jquery'], function () {
 
        // 操作对象
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(login)',function (data) {
            $.ajax({
                url:'login',
                data:data.field,
                dataType:'text',
                type:'post',
                success:function (data) {
                    if (data == 'success'){
                    	  location.href = "/user/toIndex";
                    }else{
                        layer.msg('登录名或密码错误');
                    }
                }
            })
            return false;
        })
 
    });
</script>
</body>
</html>